local skill = fk.CreateSkill{
  name = "tea__jiyong"
}
local slash_include_cards = {
  --标准
  "duel", "collateral", "savage_assault", "crossbow",
  "qinggang_sword", "spear", "blade", "double_swords", "axe",
  "halberd", "kylin_bow", "ice_sword", "nioh_shield",
  --军争
  "guding_blade", "fan", "vine",
  --用间
  "yitian_sword", "women_dress",
  --明忠
  "glittery_armor", "seven_stars_sword", "steel_lance",
  --星玉
  "sjade__talisman", "flood_attack", "chain_barrier", "attacktheunprepared", "tiger_spear",
  "taiping_flag", "qianghu_mask", "cuffed_armor",
}
local is_target_card = function (name)
  local text = Fk:translate(":" .. name)
  return string.find(text, "杀") and Fk:cloneCard(name).trueName ~= "slash"
end
---@type TrigSkelSpec<TrigFunc>
local jiyong = {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(self) and data.card then
      return is_target_card(data.card.name) and not player:prohibitUse(Fk:cloneCard("slash"))
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local card = Fk:cloneCard("slash")
    local tos = table.filter(room:getOtherPlayers(player), function(p)
      return  player:canUseTo(card, p, {
        bypass_distances = true,
        bypass_times = true,
      })
    end)
    local to = room:askToChoosePlayers(player, {
      targets = tos,
      min_num = 1,
      max_num = 1,
      skill_name = self.name,
      prompt = "#jiyong_choose"
    })
    if #to == 1 then
      event:setCostData(self, to)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local card = Fk:cloneCard("slash")
    local tos = event:getCostData(self)
    ---@type UseCardDataSpec
    local use = {
      from = player,
      tos = tos,
      card = card,
      extraUse = true,
      extra_data = {
        bypass_distances = true,
        bypass_times = true,
      },
    }
    room:useCard(use)
  end,
}
skill:addEffect(fk.CardUseFinished, jiyong)

skill:addTest(function (room, me)
  local comp2 = room.players[2]
  FkTest.runInRoom(function()
    room:handleAddLoseSkills(me, skill.name)
  end)

  local card = room:printCard("analeptic", Card.Heart, 1)
  FkTest.setNextReplies(comp2, { "__cancel", "__cancel" })
  FkTest.setNextReplies(me, { json.encode{
    card = {},
    targets = {comp2.id},
    }
  })
  FkTest.runInRoom(function()
    room:useCard{
      from = me,
      tos = { me },
      card = card,
    }
  end)
end)
return skill